import Vue from 'vue';
import Vuex from 'vuex';
Vue.use(Vuex);
const store = new Vuex.Store({
	state: {
		user: {},
		userId: null,
		token: null,
		userChatList: [],
		currentMsg: null,
		online: null,
		chatUser: {},
		chatMsgList: [],
		
	},
	actions: {

	},
	mutations: {
		SetToken: (state, token) => {
			state.token = token;
			uni.setStorageSync('token', token);
		},
		SetUser: (state, user) => {
			state.user = user;
			uni.setStorageSync('user', user);
		},
		SetUserId: (state, userId) => {
			state.userId = userId;
			uni.setStorageSync('userId', userId);
		},
		SetMessages(state, msg) {
			state.currentMsg = msg;
		},
		SetUserChatList(state, list) {
			state.userChatList = list;
			uni.setStorageSync('userChatList', list);
			
		},
		SetOnline: (state, online) => {
			state.online = online;
			uni.setStorageSync('online', online);
		},
		SetChatUser: (state, chatUser) => {
			state.chatUser = chatUser;
			uni.setStorageSync('chatUser', chatUser);
		},
		SetChatMsgList: (state, chatMsgList) => {
			state.chatMsgList = chatMsgList;
			uni.setStorageSync('chatMsgList', chatMsgList);
		},
		
		
	}
});

export default store;
